package Helper;

import com.twu.biblioteca.BibliotecaApp;
import com.twu.biblioteca.Book;
import com.twu.biblioteca.Menu;

import java.util.Iterator;
import java.util.List;

/**
 * Created by ubuntu on 4/22/14.
 */
public class Utility {
    public String listToString(List<?> things, char delimiter) {
        StringBuilder listOfThings = new StringBuilder();
        Iterator<?> list = things.iterator();
        while (list.hasNext()) {
            Object book = list.next();
            listOfThings.append(book.toString());
            if (list.hasNext())
                listOfThings.append(delimiter);
        }
        return listOfThings.toString();
    }

    public void populateMenu(BibliotecaApp bibliotecaApp) {
        bibliotecaApp.addMenu(new Menu("List Books","l"));
        bibliotecaApp.addMenu(new Menu("Quit","q"));
        bibliotecaApp.addMenu(new Menu("Checkout","c"));
        bibliotecaApp.addMenu(new Menu("Return","r"));
    }


    public void populateBooks(BibliotecaApp bibliotecaApp) {
        bibliotecaApp.addBook(new Book("TDD"));
        bibliotecaApp.addBook(new Book("Agile"));
        bibliotecaApp.addBook(new Book("SVN"));
    }
}
